package com.ljt.yupictureddd.application.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljt.yupictureddd.domain.picture.service.PictureDomainService;
import com.ljt.yupictureddd.infrastracture.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.ljt.yupictureddd.domain.picture.entity.Picture;
import com.ljt.yupictureddd.domain.user.entity.User;
import com.ljt.yupictureddd.infrastracture.mapper.PictureMapper;
import com.ljt.yupictureddd.interfaces.vo.picture.PictureVO;
import com.ljt.yupictureddd.interfaces.dto.picture.*;
import com.ljt.yupictureddd.application.service.PictureApplicationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 六件套
 * @description 针对表【picture(图片)】的数据库操作Service实现
 * @createDate 2025-03-07 19:43:57
 */
@Service
@Slf4j
public class PictureApplicationServiceImpl extends ServiceImpl<PictureMapper,Picture> implements PictureApplicationService {

    @Resource
    private PictureDomainService pictureDomainService;

    /**
     * @param pictureUploadRequest
     * @param loginUser            当前登陆的用户
     * @return
     */
    @Override
    public PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUploadRequest, User loginUser) {
        return pictureDomainService.uploadPicture(inputSource,pictureUploadRequest,loginUser);
    }

    /**
     * 填充审核参数
     *
     * @param picture
     * @param loginUser
     */
    @Override
    public void fillReviewParams(Picture picture, User loginUser) {
        pictureDomainService.fillReviewParams(picture,loginUser);
    }

    @Override
    public QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest request) {
        return pictureDomainService.getQueryWrapper(request);
    }

    /**
     * 由分页的picture对象查出分页的PictureVO对象(列表查列表)
     *
     * @param page    分页的Picture对象
     * @param request
     * @return
     */
    @Override
    public Page<PictureVO> getPictureVOList(Page<Picture> page, HttpServletRequest request) {
        return pictureDomainService.getPictureVOList(page,request);
    }

    /**
     * 审核图片
     */
    @Override
    public void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser) {
        pictureDomainService.doPictureReview(pictureReviewRequest,loginUser);
    }

    /**
     * @return
     */
    @Override
    public Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser) {
       return pictureDomainService.uploadPictureByBatch(pictureUploadByBatchRequest,loginUser);
    }


    /**
     * 删除图片
     *
     * @param id
     * @param loginUser
     */
    @Override
    public void deletePicture(Long id, User loginUser) {
        pictureDomainService.deletePicture(id,loginUser);
    }

    /**
     * 编辑图片
     *
     * @param pictureEditRequest
     * @param loginUser
     */
    @Override
    public void editPicture(PictureEditRequest pictureEditRequest, User loginUser) {
        pictureDomainService.editPicture(pictureEditRequest,loginUser);
    }

    /**
     * 根据色调查询当前空间下面的图片
     *
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    @Override
    public List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser) {
        return pictureDomainService.searchPictureByColor(spaceId,picColor,loginUser);
    }

    /**
     * 批量编辑图片
     * @param pictureEditByBatchRequest
     * @param loginUser
     */
    @Override
    public void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser){
        pictureDomainService.editPictureByBatch(pictureEditByBatchRequest,loginUser);
    }


    /**
     * 创建扩图请求
     *
     * @return
     */
    @Override
    public CreateOutPaintingTaskResponse createOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser) {
        return pictureDomainService.createOutPaintingTask(createPictureOutPaintingTaskRequest,loginUser);
    }
}




